"""
@Time ： 2021/11/15 17:26
@Auth ： ChenZhangKun
"""
import openpyxl

from Key import Key

# 获取excel
excel = openpyxl.load_workbook(r'E:\Codefiles\PyProject\pythonProject\selenium\dict.xlsx')
# 获取所有sheet
sheets = excel.sheetnames


class Out:
    # 定义
    key = None


# 遍历值
for name in sheets:
    sheet = excel[name]
    print(name)

    # 获取每个sheet值
    for value in sheet.values:
        # 序号开始
        if type(value[0]) is int:
            # 是序号开始提取数据
            data = {'name': value[2], 'value': value[3], 'txt': value[4]}
            # 将参数none全部去掉
            for key in list(data.keys()):
                if data[key] is None:
                    del data[key]
            print(data)
            if value[1] == 'open_browser':
                Out.key = Key(value[3])
            else:
                # 反射读取
                getattr(Out.key, value[1])(**data)
